Skip to content

[voq] VOQ cli show commands implementation #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 25, 2021

Conversation

vganesan-nokia
Copy link
Contributor

@vganesan-nokia vganesan-nokia commented Jun 22, 2021

What I did

Implementation of the following show commands for VOQ chassis.

  • show chassis system-ports [<system port>] {-n <namespace>}, if multi-asic voq chassis
  • show chassis system-ports [<system port>] , if single asic voq chassis
  • show chassis system-neighbors [<nbr ip address>] [-n <asic name>]
  • show chassis system-lags [<system lag>] [-n <asic name>] [-l <linecard or host name>]

The existing chassis commands under "show chassis_modules" and
"config chassis_modules" have been renamed (moved) under
"show chassis modules" and "config chassis modules" respectively

How I did it

Modified sonic utilities scripts

How to verify it

Previous command output (if the output of a command-line utility has changed)

Commands changes:

  • The commands under show chassis_modules have been moved/re-named to show chassis modules
  • The commands under config chassis_modules have been moved/re-named to config chassis modules

New command output (if the output of a command-line utility has changed)

No change in the output of the existing commands.

@lgtm-com
Copy link

lgtm-com bot commented Jun 22, 2021

This pull request introduces 3 alerts when merging 1dcbec93ed30d0030feb0ed35cee9055bbb74b2d into 5708497 - view on LGTM.com

new alerts:

  • 3 for Unused local variable

@anshuv-mfst
Copy link

Hi @ysmanman - could you please review , thanks

Copy link
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as comments

System Port Name Port Id Switch Id Core Core Port Speed
---------------------------- --------- ----------- ------ ----------- -------
Linecard1|Asic0|Ethernet0 1 0 0 1 100G
Linecard1|Asic0|Ethernet0 1 0 0 1 100G
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same output lines are repeated, is this because the same system-port information is present in every asic ?
This output is be confusing.
Can we either add

  • a new column asic_name to indicate which asic this info is retrived or
  • make the -n <asicname> mandatory for the multi asic linecards , so that the we don't display same system port information multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The same information will be repeated multiple times - as many times as the number of asics. This is because we have identical system port config in all asics. We display this multiple times so that one can verify for the requirement of indentical system port configuration in all asics.

The option to make the mandatory seems better than displaying all entries with new column since there will be lots of entries if there are many asics.

I'll implement changes to make the asic name mandatory in the command. Thanks for the suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Namespace option is made "required" option.

scripts/voqutil Outdated
"""
Get CHASSIS_APP_DB SYSTEM_NEIGH table Keys
"""
system_neigh_keys = chassis_app_db.keys(chassis_app_db.CHASSIS_APP_DB, "SYSTEM_NEIGH|*")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SYSTEM_NEIGH_TABLE_PREFIX iso SYSTEM_NEIGH| here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, here and in other places also.

scripts/voqutil Outdated
self.db = None
self.config_db = None
self.table = []
self.multi_asic = multi_asic_util.MultiAsic(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks self.multi_asic like this is not used ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed since this is not used

scripts/voqutil Outdated
self.config_db = None
self.system_lag_name = system_lag_name
self.table = []
self.multi_asic = multi_asic_util.MultiAsic(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, looks self.multi_asic like this is not used ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed since this is not used.

@lgtm-com
Copy link

lgtm-com bot commented Jul 9, 2021

This pull request introduces 1 alert when merging d66725960b6f307a8c4a0d2bbb5a55dff69e1ae6 into e8b6c5c - view on LGTM.com

new alerts:

  • 1 for Unused import

scripts/voqutil Outdated

# ========================== Common VOQ util logic ==========================

SYSTEM_PORT_TABLE_PREFIX = "SYSTEM_PORT_TABLE:"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the separator or table name defined in some python lib? If so, it would be great to import them, instead of hardcoding them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vganesan-nokia can you address @ysmanman's comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll fix this if the table names are defined in some python lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed for table names

Copy link
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as comments

scripts/voqutil Outdated

# ========================== Common VOQ util logic ==========================

SYSTEM_PORT_TABLE_PREFIX = "SYSTEM_PORT_TABLE:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vganesan-nokia can you address @ysmanman's comment ?

if ipaddress is not None:
cmd += " -a {}".format(ipaddress)

if asicname is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vganesan-nokia this change will not work on the single asic linecards right ?
I think it will be better to the add the asicname check only on multi asic linecards ?

Copy link
Contributor Author

@vganesan-nokia vganesan-nokia Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that for system neighbors and system lags this is not namespace. It is the value of DEVICE_METADATA['localhost']['asic_name'] we filter on in keys . Therefore, this will/should work on single asic linecards also for the following reasons: (1) Even for the single asic line card, in voq chassis, it is mandatory to configure DEVICE_METADATA['localhost']['asic_name']. For single asic linecards, it may be always "asic0" or "Asic0". (2) Even if the command is executed from single asic linecard, we should be able to filter the entries (from chassis app db which has info for all asics from all linecards) for asic name of other line cards that have multiple asics.

------------------------------- -------- ----------- ------------------------------------------------------
Linecard2|Asic1|PortChannel0002 1 8 Linecard2|Asic1|Ethernet16, Linecard2|Asic1|Ethernet17
"""

class TestChassisModules(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add tests for single asic line cards ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Please see my response to comment on chassis_modules.py:139-142


@chassis.command()
@click.argument('systemlagname', required=False)
@click.option('--asicname', '-x', 'asicname', default=None, type=str, show_default=False, help='Asic name')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use -n here ? similar to show chassis system_ports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For system neighbors and system lags the info are retrieved from supervisor card's chassis app db which is not in any particular namespace. The 'asicname' here is not the namespace. It is the 'asic_name' we look for in the keys of the entries.

Copy link
Contributor Author

@vganesan-nokia vganesan-nokia Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed "asicname" option selector to "-n" as suggested


@chassis.command()
@click.argument('ipaddress', required=False)
@click.option('--asicname', '-x', 'asicname', default=None, type=str, show_default=False, help='Asic name')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use -n here ? similar to show chassis system_ports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my response to comments on line# 146-149

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed "asicname" option selector to "-n" as suggested

vedganes added 7 commits August 6, 2021 10:40
Implementation of the following show commands for VOQ chassis.

   - show chassis system-ports [<system port>] [-n <namespace>] [-d all]
   - show chassis system-neighbors
   - show chassis system-lags [<system lag>]

   The existing chassis  commands under "show chassis_modules" and
   "config chassis_modules" have been renamed (moved) under
   "show chassis modules" and "config chassis modules" respectively

Signed-off-by: vedganes <[email protected]>
Following changes done to address review comments

- "-d" option is removed since this is not applicable
- namespace option is made "required" for "show system-ports" command
- "-x <asic name>" is used instead of namespace for "show
system-neibhbors" and "show system-lags" since chassis db is namespace
agnostic and also to take care of handling the case when the asic name
many not match the namespace
- "ipaddress" argument is introduced for "show system-neighbors" command
to show info for specific neighbor.

Signed-off-by: vedganes <[email protected]>
- LGTM warning fix. Removed unused import
- Adjusted system port namespace option "not required" for single asic
line cards.

Signed-off-by: vedganes <[email protected]>
- Hard coded tables names are changed to use from swsscommon schema
definition
- Added option for linecard/host name filtering on system lag.

Signed-off-by: vedganes <[email protected]>
- Changed asicname option from "-x" to "-n"
- Changed hostname option to linecardname.

Signed-off-by: vedganes <[email protected]>
@arlakshm
Copy link
Contributor

/Azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@arlakshm arlakshm merged commit 7ebb2f7 into sonic-net:master Aug 25, 2021
judyjoseph pushed a commit that referenced this pull request Aug 26, 2021
Changes in this commit
- Implementation of the following show commands for VOQ chassis.

show chassis system-ports [<system port>] {-n <namespace>}, if multi-asic voq chassis
show chassis system-ports [<system port>] , if single asic voq chassis
show chassis system-neighbors [<nbr ip address>] [-n <asic name>]
show chassis system-lags [<system lag>] [-n <asic name>] [-l <linecard or host name>]

- The existing chassis commands under "show chassis_modules" and
"config chassis_modules" have been renamed (moved) under
"show chassis modules" and "config chassis modules" respectively

Signed-off-by: vedganes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants